FROM docker.dm-ai.cn/aiet-epc/maven:3.9.6-eclipse-temurin-21-alpine

COPY . .
RUN mvn clean package -Dmaven.test.skip=true -Dmaven.source.skip=true

FROM docker.dm-ai.cn/aiet-epc/eclipse-temurin:21.0.3_9-jre-alpine

ENV TZ="Asia/Shanghai"
COPY --from=0 /target/archive-0.0.1.jar app.jar

RUN sh -c 'touch /app.jar'
ENV JAVA_OPTS="-Xms512m -Xmx2560m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/logs/heap.hprof -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -Xloggc:/logs/gc_archive_svc.log"
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=$RUNTIME_ENV -Ddruid.mysql.usePingMethod=false -jar /app.jar" ]